package com.grz.service.impl;

import com.grz.mapper.AccountMapper;
import com.grz.service.IAccountService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service
@AllArgsConstructor
public class AccountServiceImpl implements IAccountService {

    private AccountMapper accountMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void transfer(String from, String to, BigDecimal money) {
        accountMapper.outMoney(from, money);
        int num = 1 / 0;
        accountMapper.inMoney(to,money);
    }
}
